<?php include '../../../entries/restful.php';
/**
 *  维修列表
 */
class Surface extends Restful{

    public function valid(){
        return [
            'post|id|exist|id必须传递！',
            "post|state|exist|state必须传递！"
        ];
    }

    public function action(){
        $state = post('state');
        $id = post('id');
        $images_complete = post("images_complete") == "" ? "[]" : post("images_complete");
        $time = 'time_recive';
        if($state == 2) $time = 'time_complete'; 
        $now = time();
        $sql = 'update prop_fix set state = ?,' . $time . ' = ?, images_complete=? where id = ?';
        $arg = [$state,$now,$images_complete,$id];
        Mdb::write(MDB_MAIN,$sql,$arg);
        return Res::ok(['time'=>$now]);
    }
}

new Surface(); 